package com.dorm.cj.extension.container;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;

@Service
public class TestApplicationListener implements ApplicationListener<ContextRefreshedEvent> {

    private ApplicationContext applicationContext;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        this.applicationContext = contextRefreshedEvent.getApplicationContext();
    }

    public void test() {
        TestService testService = (TestService) applicationContext.getBean("testService");
        System.out.println(testService.getName("======testService=========="));
    }
}
